package com.check.dao.impl;

import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.check.dao.RoleDao;
import com.check.pojo.Resource;
import com.check.pojo.Role;

@Repository("roleDao")
public class RoleDaoImpl extends BaseSqlMapDao implements RoleDao {

	public List<Role> findRoleList(Map map) {
		return  getSqlMapClientTemplate().queryForList("Role.findRoleByPage",map);
	}
	
	@SuppressWarnings({ "unchecked", "deprecation" })
	public List<Resource> findReList(String rId) {
		
		return  this.getSqlMapClientTemplate().queryForList("Role.findAllChildByRoid",rId);
	}

	public void addRole(Role role) throws Exception {
		insertObject("Role.insertRole", role);
	}

	public void removeRole(String roId) throws Exception {
		deleteObject("Role.deleteRole", roId);
		
	}

	public Role findRoleById(String roId) throws Exception {
		return (Role) findObject("Role.findRoleById", roId);
	}

	public void updateRole(Role role) throws Exception {
		updateObject("Role.updateRole", role);
	}

	public int findRoleCount(){
		return Integer.parseInt(findObject("Role.findRoleCount").toString());
	}

	public List<Role> findAllRole() {
		return getSqlMapClientTemplate().queryForList("Role.findAllRole");
	}

	
	

}
